<template>
  <div class="films">
    <div class="header">
      <div class="header-1">
        <van-icon name="bars" size="24" @click="goCategory" />
      </div>
      <div class="header-2" @click="goSearch()">
        <van-search placeholder="请输入搜索关键词" background="#ec615b" shape="round" />
      </div>
      <div class="header-3" v-if="!content.token">
        <div @click="goLogin">登录</div>
      </div>
      <div class="header-3" v-else>
        <img :src="content.img" alt="" @click="$router.push({ name: 'content' })" />
      </div>
    </div>
    <div class="blankBox"></div>
    <div class="classify">
      <div class="classify_1">
        <FilmsClassify />
      </div>
    </div>
    <div class="recommendBox">
      <FilmsRecommend />
    </div>
    <div class="commodity">
      <FilmsShow />
    </div>
    <!-- <van-cell class="Jump" v-for="item in list" :key="item" :title="item" /> -->
    <van-back-top
      offset="500"
      right="9px"
      bottom="120px"
      style="background-color: rgba(255, 255, 255, 0.8); color: #b6b7b9; width: 38px; height: 38px"
    />
  </div>
</template>

<script setup lang="ts">
import router from '@/router'
import FilmsClassify from './components/films-classify.vue'
import FilmsRecommend from './components/films-recommend.vue'
import FilmsShow from './components/films-show.vue'
import { useContentStore } from '@/stores/content'

const content = useContentStore()

// 跳转至分类页面
function goCategory() {
  router.push({ name: 'category' })
}

// 跳转至登录页面
function goLogin() {
  router.push({ name: 'login' })
}

// 跳转至搜索页面
function goSearch() {
  router.push({ name: 'search' })
}

defineExpose({
  name: 'films'
})
</script>

<style scoped>
.films {
  width: 100%;
  height: 100%;
  background-color: #f6f6f6;
  overflow: auto;
}
.header {
  width: 100%;
  height: 44px;
  background-color: #ff5454;
  position: fixed;
  display: flex;
  justify-content: space-between;
  line-height: 44px;
  z-index: 999;
}

.van-search {
  padding: 0;
  height: 28px;
  margin-top: 5px;
}
.header-1 {
  width: 40px;
  padding-left: 15px;
  box-sizing: border-box;
}
.header-2 {
  line-height: 44px;
  width: 274px;
  padding: 5px;
}
.header-3 {
  width: 40px;
  font-size: 14px;
  position: relative;
}
.header-3 > img {
  width: 90%;
  border-radius: 50%;
  position: absolute;
  margin-top: 6px;
}

.blankBox {
  width: 100%;
  height: 44px;
  background-color: rgb(236, 97, 91);
}
.classify {
  width: 100%;
  height: 96px;
  background: linear-gradient(#ff5454, #f4f4f4);
  padding: 6px 8px 0 8px;
  box-sizing: border-box;
}
.classify_1 ul {
  display: flex;
}
.recommendBox {
  width: 100%;
  height: 106px;
  background-color: #f6f6f6;
  box-sizing: border-box;
  padding: 6px 10px;
}
.commodity {
  width: 100%;
  height: 2000px;
}
</style>
